package xyz.zxcwxy999.news.dao;

import org.apache.ibatis.annotations.*;
import xyz.zxcwxy999.news.entity.Comment;
import xyz.zxcwxy999.news.entity.News;

@Mapper
public interface CommentDao {


    /**
     * 创建一条评论
     * @param comment
     * @return
     */
    @Insert("insert into news (nid,message,date) values (#{comment.nid},#{comment.message},#{news.date})")
    int addOneNews(@Param("comment") Comment comment);

    /**
     * 获取一条新闻下的所有评论
     * @return
     */
    @Select("select * from comment where nid=#{id}")
    Comment[] getAllComments(@Param("id")int id);

    /**
     * 删除一条评论
     * @param id
     * @return
     */
    @Delete("delete from comment where cid=#{id}")
    int deleteOneComment(@Param("id")int id);
}
